﻿using DotnetSpider.Core;
using DotnetSpider.Core.Pipeline;
using Microsoft.Extensions.Logging;
using Spider_Demo.Common;
using Spider_Demo.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Text;

namespace Spider_Demo.Pipeline
{
    class NetBiAn_Pipeline : BasePipeline
    {
        public override void Process(IEnumerable<ResultItems> resultItems, ISpider spider)
        {
            foreach (var resultItem in resultItems)
            {
                //Console.WriteLine((resultItem.Results["BiAn_ImgList"] as List<Images>).Count);

                foreach (var item in resultItem.Results["BiAn_ImgList"] as List<BiAn_Images>)
                {
                    var status= HttpHelper.SaveFile(item.HD_ImgUrl, item.ImgTitle, $"彼岸桌面/{item.ImgType}");
                    Console.WriteLine($"【彼岸桌面】“{item.ImgTitle}.jpg”的下载结果：{status}");
                }

            }
        }
    }
}
